#!/bin/bash

usage() {
  echo "Usage: $(basename $0) [rust | rust-bytes | pcre1 | pcre2 | re2 | onig | tcl ]" >&2
  exit 1
}

if [ $# = 0 ] || [ $1 = '-h' ] || [ $1 = '--help' ]; then
  usage
fi

which="$1"
shift
case $which in
  rust)
    exec cargo bench --bench bench --features re-rust "$@"
    ;;
  rust-bytes)
    exec cargo bench --bench bench --features re-rust-bytes "$@"
    ;;
  re2)
    exec cargo bench --bench bench --features re-re2 "$@"
    ;;
  pcre1)
    exec cargo bench --bench bench --features re-pcre1 "$@"
    ;;
  pcre2)
    exec cargo bench --bench bench --features re-pcre2 "$@"
    ;;
  onig)
    exec cargo bench --bench bench --features re-onig "$@"
    ;;
  tcl)
    exec cargo bench --bench bench --features re-tcl "$@"
    ;;
  *)
    usage
    ;;
esac
